/*
 * Alarm.h
 *
 * This file contains the structure that defines
 * what an "Alarm" is.
 *
 *  Created on: Mar 5, 2012
 *      Author: mikaelgra
 */

#ifndef _ALARM_H
#define _ALARM_H

/**
 * Enum used to represent the different states an alarm can be in.
 */
typedef enum
{
	eEnabled,
	eDisabled,
	eTriggered,
	eStarted
} enAlarmState_t;

/**
 * Struct representing the alarm
 */
struct stAlarm_t
{
	char *name;
	char *twitterMessage;
	char *password;
	int triggerTime;
	int timeSinceTrigger;
	int triggerValue;
	int gpioPin;
	enAlarmState_t enAlarmState;
};

/**
 * Constructs a new Alarm and places it on the heap. Before this goes
 * out of scope Alarm_Finalize() must be called on the returned alarm.
 *
 * @param name
 * 		This is the name of the alarm
 * @param twitterMessage
 * 		This is the message that will be displayed on twitter
 * @param password
 * 		This is the password that is needed to disarm is the alarm
 * @param triggerTime
 * 		This is the time it takes from the alarm is in triggered state
 * 		until it goes into the started state
 * @param triggerValue
 * 		This is the value the GPIO pin should have for it to trigger
 * @param gpioPin
 * 		This is the GPIO pin that will be used
 *
 * @return
 * 		This is the newly constructed alarm.
 */
struct stAlarm_t* Alarm_New(char *name, char *twitterMessage, char *password, int triggerTime, int triggerValue, int gpioPin);

/**
 * Destructs the the alarm, freeing up the heap memory.
 *
 * @param alarm
 * 		This is the alarm to be destructed.
 */
void Alarm_Finalize(struct stAlarm_t* alarm);

#endif
